---
{% for configlet in shared_server %}
{% if shared_master[configlet] is defined %}
{% if shared_master[configlet]['last_changed'] < shared_server[configlet]['last_changed'] %}
{{configlet}}:
   source: "updated_by_{{inventory_hostname}}"
   config: "{{ shared_server[configlet]['config'] | replace('\n', '\\n')}}"
   last_changed: {{shared_server[configlet]['last_changed']}}
   devices: {{shared_server[configlet]['devices'] | replace("u'", "'")}}
   containers: {{shared_server[configlet]['containers'] | replace("u'", "'")}}
{% else %}
{{configlet}}:
   source: "updated_by_common_master"
   config: "{{ shared_master[configlet]['config'] | replace('\n', '\\n')}}"
   last_changed: {{shared_master[configlet]['last_changed']}}
   devices: {{shared_master[configlet]['devices'] | replace("u'", "'")}}
   containers: {{shared_master[configlet]['containers'] | replace("u'", "'")}}
{% endif %}
{% else %}
{{configlet}}:
   source: "add_by_{{inventory_hostname}}"
   config: "{{ shared_server[configlet]['config'] | replace('\n', '\\n')}}"
   last_changed: {{shared_server[configlet]['last_changed']}}
   devices: {{shared_server[configlet]['devices'] | replace("u'", "'")}}
   containers: {{shared_server[configlet]['containers'] | replace("u'", "'")}}
{% endif %}
{% endfor %}
{% for configlet in shared_master %}
{% if shared_server[configlet] is not defined %}
{{configlet}}:
   source: "added_by_common_master"
   config: "{{ shared_master[configlet]['config'] | replace('\n', '\\n')}}"
   last_changed: {{shared_master[configlet]['last_changed']}}
   devices: {{shared_master[configlet]['devices'] | replace("u'", "'")}}
   containers: {{shared_master[configlet]['containers'] | replace("u'", "'")}}
{% endif %}
{% endfor %}
